using net_work.Common.Request;
using net_work.Common.Result;

namespace net_work.IRepository;

public interface IRepository<T> where T : class
{
    /// <summary>
    /// 获取所有对象
    /// </summary>
    /// <returns>对象列表</returns>
    Task<IEnumerable<T>> GetAllAsync();

    /// <summary>
    /// 分页查询
    /// </summary>
    /// <param name="request">查询参数</param>
    /// <returns>分页结果</returns>
    Task<PagedResult<T>> GetPagedAsync(PagedRequest request);

    /// <summary>
    /// 分页查询（联合查询）
    /// </summary>
    /// <param name="query">查询对象</param>
    /// <param name="request">查询参数</param>
    /// <typeparam name="TB">查询对象类型</typeparam>
    /// <returns></returns>
    Task<PagedResult<TB>> GetPagedQueryResultAsync<TB>(IQueryable<TB> query, PagedRequest request);

    /// <summary>
    /// 根据主键获取对象
    /// </summary>
    /// <param name="id">主键</param>
    /// <returns>对象</returns>
    Task<T?> GetByIdAsync(long id);

    /// <summary>
    /// 删除记录（软删除）
    /// </summary>
    /// <param name="id">主键</param>
    /// <returns>删除结果</returns>
    Task<bool> DeleteByIdAsync(long id);

    /// <summary>
    /// 批量删除记录（软删除）
    /// </summary>
    /// <param name="ids">主键列表</param>
    /// <returns>删除结果</returns>
    Task<bool> DeleteByIdsAsync(List<long> ids);

    /// <summary>
    /// 批量验证
    /// </summary>
    /// <param name="list">对象列表</param>
    /// <returns>验证结果</returns>
    Task<bool> ValidateByList(List<long> list);
}